//
//  TBBTagImageView.m
//  MuYing
//
//  Created by tbb on 2019/12/30.
//  Copyright © 2019 TBB. All rights reserved.
//

#import "TBBTagImageView.h"
#import "TBBTagImageDefine.h"
#import "TBBTagModel.h"
@interface TBBTagImageView ()

@end

@implementation TBBTagImageView
- (void)layoutSubviews {
    [super layoutSubviews];
    self.userInteractionEnabled = YES;
}

#pragma --mark 添加标签
-(void)addTagWithInfoArr:(NSArray <TBBTagModel *> *) infoArr {
    for (TBBTagModel *tagModel in infoArr) {
        ZYPositionProportion arrowCenterProportion = tagModel.arrowCenterProportion;
        CGFloat px = arrowCenterProportion.x;
        CGFloat py = arrowCenterProportion.y;
        CGFloat cx = self.width * px;
        CGFloat cy = self.height * py;
        [self addTagWithTitle:tagModel.title point:CGPointMake(cx, cy) state:tagModel.pointState editEnabled:NO object:nil];
    }
}
-(void)addTagWithTitle:(NSString *)title point:(CGPoint)point state:(ZYTagViewState)state  editEnabled:(BOOL)editEnabled object:(id)object
 {
     self.userInteractionEnabled = editEnabled;
    
     TBBTagView *tagView = [[TBBTagView alloc] initWithFrame:CGRectMake(0, 0,kXSpace ,kXSpace ) title:title state:ZYTagViewStateArrowLeft];
     tagView.isEditEnabled = editEnabled;
     [self.tagViewArr addObject:tagView];
     tagView.center = point;
     ws(tagView);
     ws(self);
     tagView.deleteAction = ^{
         [weakself.tagViewArr removeObject:weaktagView];
     };
     [self addSubview:tagView];
     
}

-(NSMutableArray *)tagViewArr {
    if (!_tagViewArr) {
        _tagViewArr = [NSMutableArray array];
    }
    return _tagViewArr;
}

@end
